//
//  LBJobMBTIIntroducationView.m
//  app
//
//  Created by 刘文扬 on 17/5/9.
//  Copyright © 2017年 NAICAI LI. All rights reserved.
//

#import "LBJobMBTIIntroducationView.h"
#define SCREEN_W UIScreen.mainScreen.bounds.size.width
#import <Masonry/Masonry.h>
#import "NSString+LBAlert.h"
#import "UIButton+LBAlert.h"
@interface LBJobMBTIIntroducationView ()



/** imageView*/
@property(nonatomic,strong)UIImageView *imageView;

/** contentLabel*/
@property(nonatomic,strong)UILabel *contentLabel;


/** 子标题*/
@property(nonatomic,strong)UILabel *subTitleLabel;

/** contentLabel*/
@property(nonatomic,strong)UILabel *subContentLabel;

/** bottomButton*/
@property(nonatomic,strong)UIButton *bottomButton;

/** immanentHeight*/
@property(nonatomic,assign)CGFloat immanentHeight;


@end

@implementation LBJobMBTIIntroducationView

-(instancetype)init
{
    self = [super initWithFrame:CGRectZero];
    if (self) {
        [self initSubviews];
        
    }
    return self;
}

-(void)initSubviews
{
    self.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.contentLabel];
    [self addSubview:self.imageView];
    [self addSubview:self.subTitleLabel];
    [self addSubview:self.subContentLabel];
    [self addSubview:self.bottomButton];
    

    
    self.immanentHeight += 43;
    
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.offset(0);
        make.trailing.offset(0);
        make.top.equalTo(self).offset(0);
    }];
    
    self.immanentHeight += 15;
    
    [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentLabel.mas_bottom).offset(10);
        make.size.mas_equalTo(CGSizeMake(270, 124));
        make.centerX.offset(0);
    }];
    
    self.immanentHeight += 10;
    self.immanentHeight += 124;
    
    [self.subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.imageView.mas_bottom).offset(15);
        make.centerX.offset(0);
    }];
    
    self.immanentHeight += 15;
    
    [self.subContentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.subTitleLabel.mas_bottom).offset(3);
        make.leading.offset(50);
        make.trailing.offset(-50);
    }];
    
    self.immanentHeight += 3;
    self.immanentHeight += 55;
    
    [self.bottomButton addTarget:self action:@selector(OKAction:) forControlEvents:UIControlEventTouchUpInside];
    
    self.immanentHeight += 80;
    
    CGFloat contentHeight = [NSString getTextHeightWithText:[self content] Font:self.contentLabel.font Width:SCREEN_W - 100];
    
    self.immanentHeight += contentHeight;
    
    self.frame = CGRectMake(0, 0, self.frame.size.width, self.immanentHeight);
}
- (void)layoutSubviews{
    [super layoutSubviews];
    [self mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(self.immanentHeight-50);
    }];
}
-(void)OKAction:(UIButton *)button
{
    //[self lb_hide];
}

-(NSString *)title
{
    return @"关于联结建设人才测评";
}

-(NSString *)content
{
    return @"MBTI (Myers-Briggs Type Indicator)，是一份性格自测问卷。它由美国的心理学家Katherine Cook Briggs (1875-1968) 和她的心理学家女儿Isabel Briggs Myers根据瑞士著名的心理分析学家Carl G. Jung (荣格)的心理类型理论和她们对于人类性格差异的长期观察和研究而著成。经过了长达50多年的研究和发展，MBTI已经成为了当今全球最为著名和权威的性格测试。它的应用领域包括：";
}

-(NSString *)subTitle
{
    return @"职业与性格的4个维度框架";
}

-(NSString *)subContent
{
    return @"1、精力来源： E-Extrovert 外向 ＆ I-Introvert内向\n2、收集信息： S-Sensing实感 ＆ N-iNtuitive直觉";
}



-(UILabel *)contentLabel
{
    if (_contentLabel == nil) {
        NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
        [paragraphStyle setLineSpacing:5];
        UILabel *label = [[UILabel alloc] init];
        label.font = [UIFont systemFontOfSize:13];
        label.textColor = [UIColor colorWithRed:69/255.0 green:69/255.0 blue:69/255.0 alpha:1.0];
        label.numberOfLines = 0;
        _contentLabel = label;
        
        
        NSMutableAttributedString *attributed = [[NSMutableAttributedString alloc] initWithString:[self content]];
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithAttributedString:attributed];
        [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [attributedString length])];
        _contentLabel.attributedText = attributedString;
        
    }
    return _contentLabel;
}

-(UILabel *)subTitleLabel
{
    if (_subTitleLabel == nil) {
        
        UILabel *label = [[UILabel alloc] init];
        label.font = [UIFont systemFontOfSize:13];
        label.textColor = [UIColor colorWithRed:87/255.0 green:87/255.0 blue:87/255.0 alpha:1.0];
        label.numberOfLines = 1;
        _subTitleLabel = label;
        _subTitleLabel.text = [self subTitle];
        
    }
    return _subTitleLabel;
}

-(UILabel *)subContentLabel
{
    if (_subContentLabel == nil) {
        
        UILabel *label = [[UILabel alloc] init];
        label.font = [UIFont systemFontOfSize:10];
        label.textColor =  [UIColor colorWithRed:144/255.0 green:144/255.0 blue:144/255.0 alpha:1.0];
        label.numberOfLines = 0;
        label.textAlignment = NSTextAlignmentCenter;
        _subContentLabel = label;
        _subContentLabel.text = [self subContent];
        
    }
    return _subContentLabel;
}

-(UIImageView *)imageView
{
    if (_imageView == nil) {
        
        _imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"测评说明"]];
        
    }
    return _imageView;
}

-(UIButton *)bottomButton
{
    if (_bottomButton == nil) {
        
        _bottomButton = [UIButton lb_bottomButtonWithTitle:@"好的，我知道了"];
        
    }
    return _bottomButton;
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
